<template>
  <div class="app-container">
    <div class="filter-container">
    	<el-button @click="parameterSet" type="warning">推送参数设置</el-button>
      <el-button @click="userSet" type="success">低活跃用户定义</el-button>
    </div>

    <el-table stripe :key='tableKey' :data="list" element-loading-text="加载中..." border fit v-loading="listLoading" highlight-current-row style="width: 100%">
    	<el-table-column prop="recName" label="用户类型" align="center"></el-table-column>
    	<el-table-column prop="rltj" label="热力推荐" align="center"></el-table-column>
    	<el-table-column prop="content" label="基于内容推荐" align="center"></el-table-column>
    	<el-table-column prop="xtgl" label="协同过滤推荐" align="center"></el-table-column>
    	<el-table-column prop="recUser" label="用户资讯画像推荐" align="center"></el-table-column>
      <el-table-column align="center" label="操作" width="150" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button style="width: auto" type="success" size="mini" @click="handleUpdate(scope.row)">推荐比例修改</el-button>
        </template>
      </el-table-column>
    </el-table>
		<el-dialog title="低活跃用户定义" :visible.sync="dialogFormUser" :closeOnClickModal='false'>
      <el-form :rules="userFormRules" ref="userForm" :model="userTemp" label-position="left" label-width="149px" style='margin: 24px;'>
        <el-form-item label="使用时间小于" prop="useTime">
        	<el-input v-model.trim="userTemp.useTime" :maxlength='11' placeholder="请输入正整数"><template slot="append">天</template></el-input>
        	<!--<el-input v-model.number="userTemp.useTime" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">天</template></el-input>-->
        </el-form-item>
        <el-form-item label="资讯访问次数小于" prop="newsAccess">
        	<el-input v-model.trim="userTemp.newsAccess" :maxlength='11' placeholder="请输入正整数"><template slot="append">次</template></el-input>
        </el-form-item>
        <el-form-item label="日均访问次数小于" prop="datAccess">
        	<el-input v-model.trim="userTemp.datAccess" :maxlength='11' placeholder="请输入正整数"><template slot="append">次</template></el-input>
        </el-form-item>
        <el-form-item label="近三天访问次数小于" prop="threeAccess">
        	<el-input v-model.trim="userTemp.threeAccess" :maxlength='11' placeholder="请输入正整数"><template slot="append">次</template></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormUser = false">取消</el-button>
        <el-button type="primary" @click="updateUser">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="dialogStatus" :visible.sync="dialogFormVisible" :closeOnClickModal='false'>
      <el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="140px" style='margin: 24px;'>
        <el-form-item label="热力推荐" prop="rltj">
        	<el-input v-model.trim="temp.rltj" :maxlength='11' placeholder="请输入正整数"><template slot="append">%</template></el-input>
        </el-form-item>
        <el-form-item label="基于内容推荐" prop="content">
        	<el-input v-model.trim="temp.content" :maxlength='11' placeholder="请输入正整数"><template slot="append">%</template></el-input>
        </el-form-item>
        <el-form-item label="协同过滤推荐" prop="xtgl">
        	<el-input v-model.trim="temp.xtgl" :maxlength='11' placeholder="请输入正整数"><template slot="append">%</template></el-input>
        </el-form-item>
        <el-form-item label="用户资讯画像推荐" prop="recUser">
        	<el-input v-model.trim="temp.recUser" :maxlength='11' placeholder="请输入正整数"><template slot="append">%</template></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="updateData">确定</el-button>
      </div>
    </el-dialog>
    
    <el-dialog fullscreen :title="'推荐参数管理'" :visible.sync="dialogParameterSet">
  		<el-form ref="recommendManage" :model="recommendManage" label-position="left" label-width="152px" style='margin: auto; max-width: 1200px'>
	    	<p class="secondTitle">基于热力推荐</p>
	    	<el-row :gutter="20">
				  <el-col :span="8">  
				  	<el-form-item label="默认初始热度W0" prop="heatRd">
					    <el-input v-model="recommendManage.heatRd" disabled></el-input>
					  </el-form-item>
				  </el-col>
			  	<el-col :span="8">  
				  	<el-form-item label="用户规模系数" prop="heatGmxs">
					    <el-input v-model="recommendManage.heatGmxs" disabled></el-input>
					  </el-form-item>
				  </el-col>
		  		<el-col :span="8">  
				  	<el-form-item label="新闻初始系数" prop="heatXs">
					    <el-input v-model.number="recommendManage.heatXs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xW0</template></el-input>
					  </el-form-item>
				  </el-col>
		  		<el-col :span="8">  
				  	<el-form-item label="研报初始系数" prop="heatYbxs">
					    <el-input v-model.number="recommendManage.heatYbxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xW0</template></el-input>
					  </el-form-item>
				  </el-col>
	  			<el-col :span="8">  
				  	<el-form-item label="默认公告分类系数T0" prop="heatGgxs">
					    <el-input v-model.number="recommendManage.heatGgxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xW0</template></el-input>
					  </el-form-item>
				  </el-col>
		  		<el-col :span="8">  
				  	<el-form-item label="公告初始系数" prop="heatCsxs">
					    <el-input v-model.number="recommendManage.heatCsxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xT0xW0</template></el-input>
					  </el-form-item>
				  </el-col>
	  			<el-col :span="24">  
				  	<el-form-item label="公告分类热度" prop="recommendRltj">
	  		      <el-button style="margin-bottom: 12px;" @click="handleCreate(0)" type="success" icon="el-icon-plus">添加公告分类</el-button>
		        	<el-table stripe :data="recommendRltj" style="width: 100%" border fit highlight-current-row>
					    	<el-table-column prop="recType" label="公告类型" align="center">
					    		<template slot-scope="scope">
			              <el-select default-first-option v-model="scope.row.noticeId" :disabled="!scope.row.isAdd">
                    	<el-option
									      v-for="item in options"
									      :key="item.noticeId"
									      :label="item.noticeName"
									      :value="item.noticeId"
									      @click.native='scope.row.noticeName = item.name'>
									    </el-option>
			              </el-select>
				    			</template>
					    	</el-table-column>
					    	<el-table-column prop="blxs" label="比例系数" align="center">
					    		<template slot-scope="scope">
               			<el-input v-model.number="scope.row.blxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
               		</template>
					    	</el-table-column>
					      <el-table-column align="center" label="操作" width="150" class-name="small-padding fixed-width">
					        <template slot-scope="scope">
					          <el-button style="width: auto" type="danger" size="mini" @click.native.prevent="deleteRow(scope.$index, recommendRltj)">删除</el-button>
					        </template>
					      </el-table-column>
					    </el-table>
					  </el-form-item>
				  </el-col>
  				<el-col :span="24">  
				  	<el-form-item label="交互系数" prop="heat_interaction">
		        	<el-table stripe :data="heat_interaction" style="width: 100%" border fit highlight-current-row>
					    	<el-table-column prop="label" label="交互类型" align="center"></el-table-column>
					    	<el-table-column prop="value" label="交互得分" align="center"></el-table-column>
					    </el-table>
					  </el-form-item>
				  </el-col>
	  			<el-col :span="8">  
				  	<el-form-item label="用户规模平衡系数" prop="heatPhxs">
					    <el-input v-model.number="recommendManage.heatPhxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="8">  
				  	<el-form-item label="时间衰减系数" prop="heatSjxs">
					    <el-input v-model.number="recommendManage.heatSjxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="8">  
				  	<el-form-item label="时间范围" prop="heatSjfw">
					    <el-input v-model.number="recommendManage.heatSjfw" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
					  </el-form-item>
				  </el-col>
				</el-row>
	    	<p class="secondTitle" style="margin-top: 30px;">基于内容推荐</p>
	    	<el-row :gutter="20">
  				<el-col :span="24">  
				  	<el-form-item label="交互系数" prop="content_interaction">
		        	<el-table stripe :data="content_interaction" border style="width: 100%">
					    	<el-table-column prop="label" label="交互类型" align="center"></el-table-column>
					    	<el-table-column prop="value" label="交互得分" align="center"></el-table-column>
					    </el-table>
					  </el-form-item>
				  </el-col>
	  			<el-col :span="8">  
				  	<el-form-item label="用户规模平衡系数" prop="contentPhxs">
					    <el-input v-model.number="recommendManage.contentPhxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="8">  
				  	<el-form-item label="时间衰减系数" prop="contentSjxs">
					    <el-input v-model.number="recommendManage.contentSjxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="8">  
				  	<el-form-item label="时间范围" prop="contentSjfw">
					    <el-input v-model.number="recommendManage.contentSjfw" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
					  </el-form-item>
				  </el-col>
					<el-col :span="12">  
				  	<el-form-item label="内容推荐推荐周期" prop="contentTjzq">
					    <el-input v-model.number="recommendManage.contentTjzq" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">H</template></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="12">  
				  	<el-form-item label="最近点击文章计算范围" prop="contentJsfw">
					    <el-input v-model.number="recommendManage.contentJsfw" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">次</template></el-input>
					  </el-form-item>
				  </el-col>
				</el-row>
	    	<p class="secondTitle" style="margin-top: 30px;">基于协同过滤推荐</p>
    		<el-row :gutter="20">
  				<el-col :span="24">  
				  	<el-form-item label="同类推荐访问阈值" prop="recommendUsertype">
		        	<el-table stripe :data="recommendUsertype" border style="width: 100%" height="352">
					    	<el-table-column prop="usertypeName" label="用户类型" align="center">
      		        <template slot-scope="scope">
      		        	<span>偏好{{scope.row.usertypeName}}</span>
					        </template>
					    	</el-table-column>
					    	<el-table-column prop="usertypeValue" label="推荐阈值" align="center">
					    		<template slot-scope="scope">
					    			<el-input v-model.number="scope.row.usertypeValue" :maxlength='3' @change="keepThree(scope.row.usertypeValue, scope.$index, recommendUsertype)"><template slot="append">%</template></el-input>
					    		</template>
					    	</el-table-column>
					    </el-table>
					  </el-form-item>
				  </el-col>
  				<el-col :span="12">  
				  	<el-form-item label="协同过滤计算周期" prop="filterCycle">
					    <el-input v-model.number="recommendManage.filterCycle" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">H</template></el-input>
					  </el-form-item>
				  </el-col>
				</el-row>
	    	<p class="secondTitle" style="margin-top: 30px;">基于用户资讯画像推荐</p>
    		<el-row :gutter="20">
	  			<el-col :span="12">  
				  	<el-form-item label="新闻初始系数" prop="userXs">
					    <el-input v-model.number="recommendManage.userXs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xW0</template></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="12">  
				  	<el-form-item label="研报初始系数" prop="userYbxs">
					    <el-input v-model.number="recommendManage.userYbxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xW0</template></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="12">
				  	<el-form-item label="默认公告分类系数T0" prop="userGgxs">
					    <el-input v-model.number="recommendManage.userGgxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xW0</template></el-input>
					  </el-form-item>
				  </el-col>
					<el-col :span="12">  
				  	<el-form-item label="公告初始系数" prop="userCsxs">
					    <el-input v-model.number="recommendManage.userCsxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">xT0xW0</template></el-input>
					  </el-form-item>
				  </el-col>
  				<el-col :span="24">  
				  	<el-form-item label="公告分类热度" prop="recommendUser">
				  		<el-button style="margin-bottom: 12px;" @click="handleCreate(1)" type="success" icon="el-icon-plus">添加公告分类</el-button>
		        	<el-table stripe :data="recommendUser" border style="width: 100%">
					    	<el-table-column prop="recType" label="公告类型" align="center">
					    		<template slot-scope="scope">
			              <el-select default-first-option v-model="scope.row.noticeId" :disabled="!scope.row.isAdd">
                    	<el-option
									      v-for="item in options"
									      :key="item.noticeId"
									      :label="item.noticeName"
									      :value="item.noticeId"
									      @click.native='scope.row.noticeName = item.name'>
									    </el-option>
			              </el-select>
				    			</template>
					    	</el-table-column>
					    	<el-table-column prop="blxs" label="比例系数" align="center">
					    		<template slot-scope="scope">
               			<el-input v-model.number="scope.row.blxs" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"></el-input>
               		</template>
					    	</el-table-column>
					      <el-table-column align="center" label="操作" width="150" class-name="small-padding fixed-width">
					        <template slot-scope="scope">
					          <el-button style="width: auto" type="danger" size="mini" @click.native.prevent="deleteRow(scope.$index, recommendUser)">删除</el-button>
					        </template>
					      </el-table-column>
					    </el-table>
					  </el-form-item>
				  </el-col>
					<el-col :span="24">  
				  	<el-form-item label="用户信息权重" prop="userInfo">
		        	<el-table stripe :data="userInfo" border style="width: 100%">
					    	<el-table-column prop="label" label="相关行为" align="center"></el-table-column>
					    	<el-table-column prop="value" label="行为分值" align="center">
					    		<template slot-scope="scope">
					    			<el-input v-model.number="scope.row.value" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">%</template></el-input>
					    		</template>
					    	</el-table-column>
					    </el-table>
					  </el-form-item>
				  </el-col>
					<el-col :span="24">  
				  	<el-form-item label="资讯标签权重" prop="recommendTag">
		        	<el-table stripe :data="recommendTag" border style="width: 100%">
					    	<el-table-column prop="tagName" label="相关行为" align="center"></el-table-column>
					    	<el-table-column prop="tagValue" label="行为分值" align="center">
					    		<template slot-scope="scope">
					    			<el-input v-model.number="scope.row.tagValue" @keyup.native="proving($event)" :maxlength='11' placeholder="请输入正整数"><template slot="append">%</template></el-input>
					    		</template>
					    	</el-table-column>
					    </el-table>
					  </el-form-item>
				  </el-col>
				</el-row>
    	</el-form>
	  	<span slot="footer" class="dialog-footer">
    		<el-button type="warning" :loading="fresh" @click="backData">恢复默认</el-button>
		    <el-button type="primary" @click="saveParameter">确 定</el-button>
		    <el-button @click="dialogParameterSet = false">取 消</el-button>
		  </span>
    </el-dialog>
  </div>
</template>

<script>
  import { getDhyList, postDhyList, getTableData, updateTjblList, getManageList, saveManageList, getGgList } from '@/api/recommend'

  export default {
    name: 'recommend',
    data() {
			let isInteger = (rule, value, callback) => {
				const reg = /^[+]{0,1}(\d+)$/g;
				if (!reg.test(value)) {
					callback(new Error('请输入正整数'))
				} else {
					callback()
				}
			}
      return {
        tableKey: 0,
        list: null,
        temp: {
        	recCode:'',
          rltj: '',
          content:'',
          xtgl: '',
          recUser:''
        },
        recommendManage:{
        	heatRd:'',
        	heatGmxs:'',
        	heatXs:'',
        	heatYbxs:'',
        	heatGgxs:'',
        	heatCsxs:'',
        	heatPhxs:'',
        	heatSjxs:'',
        	heatSjfw:'',
        	contentTjzq:'',
        	contentJsfw:'',
        	contentPhxs:'',
        	contentSjxs:'',
        	contentSjfw:'',
        	filterCycle:'',
        	userXs:'',
        	userYbxs:'',
        	userGgxs:'',
        	userCsxs:'',
        	userZxg:'',
        	userCcg:'',
        	userRec:''
        },
	    	recommendRltj: [],
	    	recommendTag: [],
	    	recommendUsertype:[],
	    	recommendUser: [],
	    	heat_interaction:[],
	    	content_interaction:[],
	    	userInfo:[],
        userTemp:{
        	useTime:'',
        	newsAccess:'',
        	datAccess:'',
        	threeAccess:''
        },
        options:[],
        fresh:false,
        listLoading: true,
        dialogFormVisible: false,
        dialogFormUser: false,
        dialogParameterSet: false,
        dialogStatus: '',
        rules: {
          rltj: [
          	{ required: true, validator: isInteger, trigger: 'blur' }
//        	{ required: true, type: 'number', message: '请输入正整数', trigger: 'blur'},
//    			{ validator: isInteger, trigger: 'blur' }
	      	],
    			recUser: [
    				{ required: true, validator: isInteger, trigger: 'blur' }
	      	],
  				content: [
  					{ required: true, validator: isInteger, trigger: 'blur' }
	      	],
  				xtgl: [
  					{ required: true, validator: isInteger, trigger: 'blur' }
	      	]
        },
    		userFormRules: {
          useTime: [
      			{ required: true, validator: isInteger, trigger: 'blur' }
          ],
    			newsAccess: [
    				{ required: true, validator: isInteger, trigger: 'blur' }
          ],
					datAccess: [
						{ required: true, validator: isInteger, trigger: 'blur' }
          ],
					threeAccess: [
						{ required: true, validator: isInteger, trigger: 'blur' }
          ]
        }
      }
    },
    created() {
      this.getList()
    },
    methods: {
    	proving(e, tar){
    		let keynum = window.event ? e.keyCode : e.which
    		if(keynum == 189 || keynum == 190 || keynum == 110 || keynum == 109){
    			this.$message({ type: 'warning', message: '请输入正整数' })
    			this.$set(e.target, 'value', '')
//				e.target.value = ''
//　　　 		tar = tar.replace(/[^\.\d]/g, '')
//      	tar = tar.replace('.', '')
    		}
    	},
		keepThree(tar, index, val){
			if(tar > 100 || tar < 0){
				this.$message({ type: 'warning', message: '输入数值需为正数且不大于100' })
				val[index].usertypeValue = 0
			}
    	},
		getList() {
			this.listLoading = true
			getTableData().then(res => {
			  this.listLoading = false
			  this.list = res.Data
			})
		},
    	deleteRow(index, rows) {
			this.$confirm('确认删除, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				rows.splice(index, 1);
			}).catch(() => {
				this.$message({ type: 'info', message: '已取消删除' })
			})
     	},
      handleCreate(tar){
      	if(tar){
      		this.recommendUser.push({
            recType: 1,
            blxs: '',
            isAdd: true,
            noticeName:'',
            noticeId: this.options[0].id
        	})
      	} else {
      		this.recommendRltj.push({
            recType: 0,
            blxs: '',
            isAdd: true,
            noticeName: '',
            noticeId: this.options[0].id
        	})
      	}
      },
      parameterSet(){
  			this.getParameterData(false)
				getGgList().then(res => {
		  		this.options = res.Data.filter(item => {
		  			item.noticeId = item.id
		  			item.noticeName = item.name
		        return item.child == 0  //child'是否叶子节点 0-是 1-否
		     	})
		    })
      	this.dialogParameterSet = true
				this.$nextTick(() => {
      		this.$refs['recommendManage'].clearValidate()
        })
      },
      getParameterData(bol){
      	if(bol) {
      		this.fresh = true
      	}
				getManageList().then(res => {
					let tar = res.Data[0]
					let formTar = tar.recommendManage
					Object.keys(this.recommendManage).forEach(item => {
						this.recommendManage[item] = formTar[item]
					})
					this.recommendRltj = Object.assign([], tar.recommendRltj)
					this.recommendUsertype = Object.assign([], tar.recommendUsertype)
					this.recommendTag = Object.assign([], tar.recommendTag)
					this.recommendUser = Object.assign([], tar.recommendUser)
        	this.heat_interaction = [
        		{ label:'点击', value: formTar.heatClick, tit: 'heatClick' },
        		{ label:'收藏', value: formTar.heatCollect, tit: 'heatCollect' },
        		{ label:'点赞', value: formTar.heatGood, tit: 'heatGood' },
        		{ label:'分享', value: formTar.heatShare, tit: 'heatShare' }
        	]
    			this.content_interaction = [
        		{ label:'点击', value: formTar.contentClick, tit: 'contentClick' },
        		{ label:'收藏', value: formTar.contentCollect, tit: 'contentCollect' },
        		{ label:'点赞', value: formTar.contentGood, tit: 'contentGood' },
        		{ label:'分享', value: formTar.contentShare, tit: 'contentShare' }
        	]
    			this.userInfo = [
	        	{ label:'自选股', value: formTar.userZxg, tit: 'userZxg' },
	        	{ label:'持仓股', value: formTar.userCcg, tit: 'userCcg' },
	        	{ label:'浏览记录', value: formTar.userRec, tit: 'userRec' }
        	]
	      	if(bol){
      		 	this.fresh = false
      		 	this.$notify({ title: '成功', type: 'success', message: '恢复成功' })
	      	}
  	 		})
      },
      backData(){
      	this.getParameterData(true)
      },
      checkTotal(){  //用户信息权重之和必须是100
      	let tot = 0
      	let _this = this
      	return new Promise(function (resolve, reject) {
      		tot = _this.recommendManage.userZxg + _this.recommendManage.userCcg + _this.recommendManage.userRec
      		if(tot == 100){
      			resolve()
      		} else {
      			reject('用户信息权重修改错误, 数值之和应为100');
      		}
				})
      },
      saveParameter(){
      	this.heat_interaction.forEach(item => {
      		let tar = item.tit
      		this.recommendManage[tar] = item.value * 1
      	})
				this.content_interaction.forEach(item => {
      		let tar = item.tit
      		this.recommendManage[tar] = item.value * 1
      	})
      	this.userInfo.forEach(item => {
      		let tar = item.tit
      		this.recommendManage[tar] = item.value * 1
      	})
      	
				Object.keys(this.recommendManage).forEach(item => {  //能改的不填默认为0
					if(this.recommendManage[item] == ''){
						this.recommendManage[item] = 0
					}
				})
				this.recommendRltj.forEach(val => {
					if(val.blxs == ''){
						val.blxs = 0
					}
				})
				this.recommendUsertype.forEach(val => {
					if(val.usertypeValue == ''){
						val.usertypeValue = 0
					}
				})
				this.recommendTag.forEach(val => {
					if(val.tagValue == ''){
						val.tagValue = 0
					}
				})
				this.recommendUser.forEach(val => {
					if(val.blxs == ''){
						val.blxs = 0
					}
				})
				this.checkTotal().then(() =>{
		    	let obj = {
		    		recommendManage: this.recommendManage,
		    		recommendRltj: this.recommendRltj,
		    		recommendUsertype: this.recommendUsertype,
		    		recommendTag: this.recommendTag,
		    		recommendUser: this.recommendUser
		    	}
		    	saveManageList(obj).then(() => {
			      this.dialogParameterSet = false
			      this.$notify({ title: '成功', message: '推送参数设置成功', type: 'success', duration: 5000 })
						this.$nextTick(() => {
		      		this.$refs['recommendManage'].clearValidate()
		        })
	    		})
				}).catch(err => {
					this.$message({ type: 'warning', message: err })
      	})
      },
      userSet() {
				getDhyList().then(res => {
					let tar = res.Data[0]
					Object.keys(this.userTemp).forEach(item => {
						this.userTemp[item] = tar[item]
					})
	        this.dialogFormUser = true
	        this.$nextTick(() => {
	      		this.$refs['userForm'].clearValidate()
	        })
		    })
      },
    	updateUser() {
        this.$refs['userForm'].validate(valid => {
          if (valid) {
				    postDhyList(this.userTemp).then(() => {
				      this.dialogFormUser = false
				      this.$notify({ title: '成功', message: '低活跃用户定义成功', type: 'success', duration: 5000 })
		    		})
          }
        })
     	},
      handleUpdate(row) {
				Object.keys(this.temp).forEach(item => {
					this.temp[item] = row[item]
				})
        this.dialogStatus = row.recName
        this.dialogFormVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
      },
      updateData() {
        this.$refs['dataForm'].validate(valid => {
          if (valid) {
          	let total = this.temp.rltj*1 + this.temp.content*1 + this.temp.xtgl*1 + this.temp.recUser*1
          	if(total == 100){ //推荐比例之和必须是100
	            updateTjblList(this.temp).then(() => {
	              this.getList()
	              this.dialogFormVisible = false
	              this.$notify({ title: '成功', message: '推荐比例修改成功', type: 'success', duration: 5000 })
	            })
          	} else {
          		this.$message({ type: 'warning', message: '推荐比例修改错误, 数值之和应为100' })
          	}
          }
        })
      }
    }
  }
</script>
<style scoped>
	.secondTitle {
    font-weight: bold;
    font-size: 17px;
    margin-bottom: 30px;
    border-bottom: 1px solid #000;
	}
</style>